package pe.edu.upc.dew.sisrest.dao.hibernate;

import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import pe.edu.upc.dew.sisrest.dao.TipoDao;
import pe.edu.upc.dew.sisrest.model.Tipo;

@Repository
public class TipoDaoHibernate extends HibernateDaoSupport implements TipoDao {

    @Autowired
    public TipoDaoHibernate(SessionFactory sessionFactory) {
		setSessionFactory(sessionFactory);
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<Tipo> obtenerListaTipos() {
        List list = getHibernateTemplate().find(" from Tipo ");
        return list;
    }

    @Override
    public Tipo obtenerTipoById(String idTipo) {
        Tipo tipo = getHibernateTemplate().get(Tipo.class, idTipo);
	return tipo;
    }

}
